package pl.streamsoft.currencyApp.services;

import java.util.ArrayList;
import java.util.List;

import pl.streamsoft.currencyApp.model.Country;

public class CountryService implements ICountryService {
	
	private List<Country> listOfCountries;

	public CountryService(){
		listOfCountries = new ArrayList<Country>();
	}
	
	public CountryService(List<Country> listOfCountries) {
		this.listOfCountries = listOfCountries;
	}

	@Override
	public Country getCountryByName(String name) {
		if(!listOfCountries.isEmpty()){
			for(Country el: listOfCountries){
				if(el.getName().equals(name))
					return el;
			}
		}
		
		return null;
	}
	
	@Override
	public void addCountryToList(Country country) {
		this.listOfCountries.add(country);
	}
	
/*	@Override
	public void setListOfCountries(List<Country> listOfCountries) {
		this.listOfCountries = listOfCountries;
	}*/
	
	@Override
	public List<Country> getListOfCountries() {
		return this.listOfCountries;
	}
}
